'use strict';

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  app.router.redirect('/', '/swagger-ui.html', 302);
  const globaladmin = require('./routers/globalAdmin');
  globaladmin.router(app);
  const tenantadmin = require('./routers/tenantAdmin');
  tenantadmin.router(app);
  const useradmin = require('./routers/userAdmin');
  useradmin.router(app);
  const olt = require('./routers/olt');
  olt.router(app);
  const oltType = require('./routers/oltType');
  oltType.router(app);
  const card = require('./routers/card');
  card.router(app);
  const ponports = require('./routers/ponPorts');
  ponports.router(app);
  const uplink = require('./routers/uplink');
  uplink.router(app);
  const vlan = require('./routers/vlan');
  vlan.router(app);
  const speed = require('./routers/speedprofile');
  speed.router(app);
  const dbaProfile = require('./routers/dbaProfile');
  dbaProfile.router(app);
  const onuProfile = require('./routers/onuProfile');
  onuProfile.router(app);
  const onu = require('./routers/onu');
  onu.router(app);
  const config = require('./routers/config');
  config.router(app);
  const mandate = require('./routers/mandate');
  mandate.router(app);
  const tr069 = require('./routers/tr069');
  tr069.router(app);
  const srvProfile = require('./routers/srvProfile');
  srvProfile.router(app);
  const lineProfile = require('./routers/lineProfile');
  lineProfile.router(app);
  const userManagement = require('./routers/userManagement');
  userManagement.router(app);
  const Menu = require('./routers/menu');
  Menu.router(app);
  const Role = require('./routers/role');
  Role.router(app);
  const OperationLog = require('./routers/operationLog');
  OperationLog.router(app);
  const User = require('./routers/user');
  User.router(app);
  const SNList = require('./routers/snList');
  SNList.router(app);
  const onuDetails = require('./routers/onuDetails');
  onuDetails.router(app);
  const oltProfile = require('./routers/oltProfile');
  oltProfile.router(app);
  const init = require('./public/initDate.js');
  // const ftpsrv = require('./public/ftpserver.js');
  const editmysql = require('./public/editmysql.js');
  const { io } = app;
  io.of('/').route('message', io.controller.default.ping);
  // 模型添加字段同步数据库
  app.beforeStart(async () => {
    // await app.model.sync({ alter: true });
    await app.modelmysql.sync({ force: false });
    await init.initDate(app);
    // await editmysql.editmysql(app);
  });
};
